var TYPES = [ 'All', 'Timeline', 'FAQ', 'Hotspot', 'Animal' ];

function showNewContent()
{
    var type = document.getElementById('type').value;  
    location = "show_new_content.php?type=" + type;
}

function initEvents()
{
    var type = document.getElementById('type');
    if ( type.addEventListener )
    {
        type.addEventListener('change', function () { showNewContent(); }, false);
    }
    else if ( type.attachEvent )
    {
        type.attachEvent('onchange', function () { showNewContent(); });
    }
}

function parseGetParams() 
{ 
   var parsedParams = [];; 
   var getString = window.location.search.substring(1).split("&"); 
   for(var i = 0; i < getString.length; i++) 
   { 
      var param = getString[i].split("="); 
      parsedParams[param[0]] = param[1]; 
   } 
   return parsedParams; 
} 

window.onload = function()
{
    initEvents(); 
   
    getParams =  parseGetParams(); 
    currType  = getParams['type'];

    if ( ( currType != '' ) && (currType != undefined) )
    {
        var i = 0;
        while ( TYPES[i] != currType )
        {
            i++;
        }
        type.options[0].text = currType;
        type.options[0].value = currType;
        type.options[i].text = 'All';
        type.options[i].value = 'All';
    } 
}